<template>
	<view class="common-list d-flex animated flipInX fast">
		<view class="common-list-left">
			<image :src="item.userpic" mode="widthFix" lazy-load></image>
		</view>
		<view class="common-list-right flex-1 ml-2">
			<view class="header d-flex jc-between ai-center">
				<view class="d-flex ai-center jc-center name">
					{{item.username}}
					<tag-sex-age :sex="item.sex" :age="item.age"></tag-sex-age>
				</view>
				<view v-if="!isFollow" class="iconfont icon-zengjia follow" @tap="follow">
					关注
				</view>
			</view>
			<view class="common-list-time">
				26天前
			</view>
			<view class="title">{{item.title}}</view>
			<view class="center">
				<!-- 图片 -->
				<view :class="{imgList:item.morepic.length > 1}">
					<block v-for="(pic,index) in item.morepic" :key="index">
						<image :src="pic" mode="widthFix" lazy-load @tap="imgDetail(index)"></image>
					</block>
				</view>
				<!-- 视频 -->
				<template v-if="item.video">
					<view class="play iconfont icon-bofang">
					</view>
					<view class="playinfo">
						{{item.video.playnum}} 次播放 {{item.video.playlong}}
					</view>
				</template>
				<!-- 分享 -->
				<view v-if="item.share" class="share d-flex jc-between ai-center">
					<image :src="item.share.sharepic" mode="widthFix" lazy-load></image>
					<view class="title flex-1 clamp2">
						{{item.share.title}}
					</view>
				</view>
			</view>
			<view class="footer d-flex jc-between ai-center">
				<view class="flex-1">
					{{item.site}}
				</view>
				<view class="d-flex jc-between ai-center">
					<view class="iconfont icon-zhuanfa">
						{{item.sharenum}}
					</view>
					<view class="iconfont icon-pinglun1">
						{{item.commentnum}}
					</view>
					<view class="iconfont icon-dianzan1">
						{{item.goodnum}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import tagSexAge from "../common/tag-sex-age.vue"
	export default {
		props: {
			item: {
				type: Object,
				required: true
			}
		},
		data() {
			return {
				isFollow: this.item.isfollow
			}
		},
		methods: {
			follow() {
				this.isFollow = true
				uni.showToast({
					title: "关注成功"
				})
			},
			// 查看图片
			imgDetail(index) {
				uni.previewImage({
					current: index,
					urls: this.item.morepic
				})
			}
		},
		components: {
			tagSexAge
		}
	}
</script>

<style lang="scss" scoped>
	@import "../../common/scss/list.scss";

	.common-list {
		border-bottom: 1upx solid #EEEEEE;

		.common-list-right {
			border-bottom: 0;
		}

		.common-list-time {
			color: #CCCCCC;
		}

		.center {
			.imgList {
				display: flex;
				justify-content: space-around;
				align-items: center;
				flex-wrap: wrap;
				width: 100%;
				height: 100%;

				image {
					width: 180upx !important;
					height: 180upx !important;
					padding: 10upx 0;
					border-radius: 20upx !important;
					overflow: hidden;
				}
			}
		}
	}
</style>
